//
//  Mythread.m
//  8多线程
//
//  Created by zhengwei on 2/13/16.
//  Copyright © 2016 zhengwei. All rights reserved.
//

#import "Mythread.h"

@implementation Mythread
-(void)testThread{
//    1 创建一个队列
     //dispatch_queue_t q = dispatch_queue_create("www.imooc.com.gcd1", DISPATCH_QUEUE_CONCURRENT);
    dispatch_queue_t q = dispatch_queue_create("www.imooc.com.gcd1", DISPATCH_QUEUE_SERIAL); //串行队列
//    2 add Queue
  
    //同步方法
    for (int i = 0 ; i < 10; i++) {
        dispatch_sync(q, ^{
            NSLog(@"%@ i=%d",[NSThread currentThread],i);
        });
    }
    
      //异步方法
//    for (int i = 0 ; i < 10; i++) {
//        dispatch_async(q, ^{
//            NSLog(@"%@ i=%d",[NSThread currentThread],i);
//        });
//        
//    }
    
}
@end
